#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

#define FOR(i,a,n) for(int i=a,_n(n);i<_n;++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

typedef pair<int,int> pii;
int main()
{
    string s;
    cin>>s;
    vector<pii> cnt(26,pii(0,0));
    REP(i,26) cnt[i].second=i;
    REP(i,s.size()) cnt[s[i]-'a'].first++;
    int k;
    cin>>k;
    sort(cnt.begin(),cnt.end());
    int p1;
    for(p1=0;p1<26&&k;p1++)
    {
        if(cnt[p1].first==0)
        {
            continue;
        }
        if(cnt[p1].first<k)
        {
            k-=cnt[p1].first;
            cnt[p1].first=0;
            continue;
        }
        else
        {
            cnt[p1].first-=k;
            k = 0;
        }
    }
    vector<bool> f(26,false);
    int m = 0;
    REP(i,26) if(cnt[i].first)
    {
        m++;
        f[cnt[i].second] = true;
    }
    cout<<m<<endl;
    REP(i,s.size()) if(f[s[i]-'a']) putchar(s[i]);
    cout<<endl;
	return 0;
}
